package gbench.sandbox.record;

import org.junit.jupiter.api.Test;
import static gbench.common.tree.LittleTree.IRecord.*;
import static gbench.common.tree.LittleTree.*;

public class JunitLisp {

    /**
     * 提取第n个元素
     * @param <T>
     * @param aa
     * @param n
     * @return
     */
    public static <T> T GET(T[] aa, int n) {
        if(n>aa.length)return null;
        return n <= 0 ? CAR(aa) : GET(CDR(aa), n - 1);
    }

    @Test
    public void foo() {
        var vv = NATS(10).reduce((Long[]) null, (aa, a) -> CONS(a, aa), (aa, bb) -> A(aa, bb));
        System.out.println(L(CDR(vv)));
        var aa = REV(vv);
        System.out.println(L(aa));
        for (int i = 0; i < vv.length; i++)
            System.out.println(GET(aa, i));
    }

}
